<template>
  <div class="portfolio-page">
    <!-- Background Elements -->
    <div class="bg-image"></div>
    <div class="bg-gradient-overlay"></div>
    
    <div class="portfolio-container">
      <!-- Header Section -->
      <div class="header-section">
        <h1 class="page-title">设计案例·创意成果展示</h1>
        
        <!-- Search and Filter Section -->
        <div class="search-filter-section">
          <!-- Search Bar -->
          <div class="search-bar">
            <input type="text" class="search-input" placeholder="搜索项目名称">
            <div class="search-icon">
              <svg viewBox="0 0 24 24" fill="currentColor">
                <path d="M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"/>
              </svg>
            </div>
          </div>
          
          <!-- Sort Dropdown -->
          <div class="sort-dropdown">
            <span class="sort-text">最新</span>
            <div class="dropdown-icon">
              <svg viewBox="0 0 24 24" fill="currentColor">
                <path d="M7 10l5 5 5-5z"/>
              </svg>
            </div>
          </div>
        </div>
        
        <!-- Category Filter Tags -->
        <div class="category-filters">
          <div class="filter-tag active">
            <span>企业设计</span>
          </div>
          <div class="filter-tag">
            <span>程序开发</span>
          </div>
          <div class="filter-tag">
            <span>海报设计</span>
          </div>
          <div class="filter-tag">
            <span>LOGO设计</span>
          </div>
          <div class="filter-tag">
            <span>展板设计</span>
          </div>
          <div class="filter-tag">
            <span>交互动画</span>
          </div>
          <div class="filter-tag">
            <span>UI设计</span>
          </div>
        </div>
      </div>
      
      <!-- Portfolio Grid -->
      <div class="portfolio-grid">
        <!-- Portfolio Items -->
        <div 
          v-for="item in portfolioItems" 
          :key="item.id"
          :class="['portfolio-item', item.size]"
          @click="goToDetail(item.id)"
        >
          <div class="portfolio-image">
            <img src="@/assets/images/demo.webp" :alt="item.title" class="portfolio-img" />
          </div>
          <div class="portfolio-overlay">
            <h3 class="project-title">{{ item.title }}</h3>
            <p class="project-category">{{ item.category }}</p>
          </div>
        </div>
      </div>
      
      <!-- Load More Button -->
      <div class="load-more-section">
        <button class="load-more-btn">
          <span>加载更多作品</span>
        </button>
      </div>
    </div>
  </div>
</template>

<script lang="ts">
import { defineComponent, ref } from 'vue';
import { useRouter } from 'vue-router';

interface PortfolioItem {
  id: number;
  title: string;
  category: string;
  image: string;
  size: 'large' | 'medium' | 'small';
}

export default defineComponent({
  name: 'PortfolioPage',
  setup() {
    const router = useRouter();
    const searchQuery = ref('');
    const selectedCategory = ref('企业设计');
    const sortBy = ref('最新');
    
    const categories = [
      '企业设计',
      '程序开发', 
      '海报设计',
      'LOGO设计',
      '展板设计',
      '交互动画',
      'UI设计'
    ];
    
    const portfolioItems = ref<PortfolioItem[]>([
      {
        id: 1,
        title: '企业品牌设计',
        category: '品牌设计',
        image: 'https://wx1.sinaimg.cn/mw690/8864d5a6gy1hxk8l8m29wj20sg16o4qp.jpg',
        size: 'large'
      },
      {
        id: 2,
        title: '移动应用界面',
        category: 'UI设计',
        image: 'https://wx1.sinaimg.cn/mw690/8864d5a6gy1hxk8l8m29wj20sg16o4qp.jpg',
        size: 'medium'
      },
      {
        id: 3,
        title: '产品海报',
        category: '海报设计',
        image: 'https://wx1.sinaimg.cn/mw690/8864d5a6gy1hxk8l8m29wj20sg16o4qp.jpg',
        size: 'small'
      },
      {
        id: 4,
        title: '网站开发',
        category: '程序开发',
        image: 'https://wx1.sinaimg.cn/mw690/8864d5a6gy1hxk8l8m29wj20sg16o4qp.jpg',
        size: 'medium'
      },
      {
        id: 5,
        title: '交互动画设计',
        category: '交互动画',
        image: 'https://wx1.sinaimg.cn/mw690/8864d5a6gy1hxk8l8m29wj20sg16o4qp.jpg',
        size: 'large'
      },
      {
        id: 6,
        title: 'LOGO设计',
        category: 'LOGO设计',
        image: 'https://wx1.sinaimg.cn/mw690/8864d5a6gy1hxk8l8m29wj20sg16o4qp.jpg',
        size: 'small'
      },
      {
        id: 7,
        title: '展板设计',
        category: '展板设计',
        image: 'https://wx1.sinaimg.cn/mw690/8864d5a6gy1hxk8l8m29wj20sg16o4qp.jpg',
        size: 'medium'
      },
      {
        id: 8,
        title: '品牌标识',
        category: '品牌设计',
        image: 'https://wx1.sinaimg.cn/mw690/8864d5a6gy1hxk8l8m29wj20sg16o4qp.jpg',
        size: 'small'
      },
      {
        id: 9,
        title: '企业官网',
        category: '程序开发',
        image: 'https://wx1.sinaimg.cn/mw690/8864d5a6gy1hxk8l8m29wj20sg16o4qp.jpg',
        size: 'large'
      },
      {
        id: 10,
        title: '产品包装',
        category: '包装设计',
        image: 'https://wx1.sinaimg.cn/mw690/8864d5a6gy1hxk8l8m29wj20sg16o4qp.jpg',
        size: 'medium'
      },
      {
        id: 11,
        title: '宣传册设计',
        category: '平面设计',
        image: 'https://wx1.sinaimg.cn/mw690/8864d5a6gy1hxk8l8m29wj20sg16o4qp.jpg',
        size: 'small'
      },
      {
        id: 12,
        title: '移动端应用',
        category: 'UI设计',
        image: 'https://wx1.sinaimg.cn/mw690/8864d5a6gy1hxk8l8m29wj20sg16o4qp.jpg',
        size: 'medium'
      }
    ]);
    
    const selectCategory = (category: string) => {
      selectedCategory.value = category;
    };
    
    const goToDetail = (id: number) => {
      router.push({ name: 'portfolio-detail', params: { id: id.toString() } });
    };
    
    return {
      searchQuery,
      selectedCategory,
      sortBy,
      categories,
      portfolioItems,
      selectCategory,
      goToDetail
    };
  }
});
</script>

<style lang="scss" scoped>
.portfolio-page {
  background: #000000;
  min-height: 100vh;
  padding: 80px 0 0 0;
  position: relative;
  overflow: hidden;
  color: #ffffff;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

// Background Elements
.bg-image {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 660px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.03) 0%, rgba(255, 255, 255, 0) 100%);
  z-index: 0;
}

.bg-gradient-overlay {
  position: absolute;
  top: 243px;
  left: 0;
  width: 100%;
  height: 418px;
  background: linear-gradient(180deg, rgba(0, 0, 0, 1) 25.48%, rgba(0, 0, 0, 0) 100%);
  z-index: 1;
}

.portfolio-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 80px 40px;
  position: relative;
  z-index: 2;
}

// Header Section
.header-section {
  margin-bottom: 60px;
  background: linear-gradient(rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0.6)), url('https://images.unsplash.com/photo-1558655146-9f40138edfeb?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=2064&q=80') center/cover no-repeat;
  background-attachment: fixed;
  margin: 0 -40px 60px -40px;
  padding: 120px 40px 80px 40px;
  position: relative;
  
  .page-title {
    font-size: 48px;
    font-weight: 700;
    color: #ffffff;
    margin: 0 0 60px 0;
    text-align: center;
    letter-spacing: -0.02em;
    line-height: 1.1;
  }
}

// Search and Filter Section
.search-filter-section {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 20px;
  margin-bottom: 40px;
  
  .search-bar {
    position: relative;
    width: 400px;
    
    .search-input {
      width: 100%;
      padding: 16px 50px 16px 20px;
      background: rgba(255, 255, 255, 0.05);
      border: 1px solid rgba(255, 255, 255, 0.1);
      border-radius: 10px;
      color: #ffffff;
      font-size: 16px;
      font-weight: 400;
      backdrop-filter: blur(10px);
      transition: all 0.3s ease;
      box-sizing: border-box;
      
      &::placeholder {
        color: rgba(255, 255, 255, 0.6);
      }
      
      &:focus {
        outline: none;
        border-color: rgba(255, 255, 255, 0.3);
        background: rgba(255, 255, 255, 0.08);
      }
    }
    
    .search-icon {
      position: absolute;
      right: 16px;
      top: 50%;
      transform: translateY(-50%);
      width: 20px;
      height: 20px;
      color: rgba(255, 255, 255, 0.6);
      
      svg {
        width: 100%;
        height: 100%;
      }
    }
  }
  
  .sort-dropdown {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 16px 20px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    
    &:hover {
      background: rgba(255, 255, 255, 0.08);
      border-color: rgba(255, 255, 255, 0.2);
    }
    
    .sort-text {
      font-size: 16px;
      font-weight: 400;
      color: rgba(255, 255, 255, 0.6);
    }
    
    .dropdown-icon {
      width: 16px;
      height: 16px;
      color: rgba(255, 255, 255, 0.6);
      
      svg {
        width: 100%;
        height: 100%;
      }
    }
  }
}

// Category Filters
.category-filters {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  
  .filter-tag {
    padding: 12px 24px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    
    &.active {
      background: linear-gradient(135deg, #007AFF 0%, #0056CC 100%);
      border-color: transparent;
      box-shadow: 0 4px 20px rgba(0, 122, 255, 0.3);
    }
    
    &:hover:not(.active) {
      background: rgba(255, 255, 255, 0.08);
      border-color: rgba(255, 255, 255, 0.2);
    }
    
    span {
      font-size: 14px;
      font-weight: 500;
      color: #ffffff;
    }
  }
}

// Portfolio Grid
.portfolio-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px;
  margin-bottom: 60px;
  
  .portfolio-item {
    position: relative;
    border-radius: 10px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s ease;
    
    &.large {
      grid-column: span 2;
      height: 300px;
    }
    
    &.medium {
      height: 250px;
    }
    
    &.small {
      height: 200px;
    }
    
    &:hover {
      transform: translateY(-8px);
      box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
      
      .portfolio-overlay {
        opacity: 1;
      }
      
      .portfolio-img {
        transform: scale(1.05);
      }
    }
    
    .portfolio-image {
      width: 100%;
      height: 100%;
      position: relative;
      overflow: hidden;
      
      .portfolio-img {
        width: 100%;
        height: 100%;
        object-fit: cover;
        border-radius: 10px;
        transition: transform 0.5s ease;
      }
      
      .image-placeholder {
        width: 100%;
        height: 100%;
        background: linear-gradient(135deg, 
          rgba(0, 122, 255, 0.1) 0%, 
          rgba(0, 86, 204, 0.1) 25%,
          rgba(255, 255, 255, 0.05) 50%,
          rgba(0, 122, 255, 0.08) 75%,
          rgba(0, 86, 204, 0.12) 100%);
        border-radius: 10px;
        position: relative;
        
        &::before {
          content: '';
          position: absolute;
          top: 20px;
          left: 20px;
          width: 60px;
          height: 60px;
          background: rgba(255, 255, 255, 0.1);
          border-radius: 50%;
        }
        
        &::after {
          content: '';
          position: absolute;
          bottom: 20px;
          right: 20px;
          width: 80px;
          height: 4px;
          background: rgba(0, 122, 255, 0.3);
          border-radius: 2px;
        }
      }
    }
    
    .portfolio-overlay {
      position: absolute;
      bottom: 0;
      left: 0;
      right: 0;
      padding: 24px;
      background: linear-gradient(180deg, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0.8) 100%);
      opacity: 0;
      transition: all 0.3s ease;
      
      .project-title {
        font-size: 18px;
        font-weight: 600;
        color: #ffffff;
        margin: 0 0 8px 0;
        line-height: 1.2;
      }
      
      .project-category {
        font-size: 14px;
        font-weight: 400;
        color: rgba(255, 255, 255, 0.7);
        margin: 0;
      }
    }
  }
}

// Load More Section
.load-more-section {
  text-align: center;
  
  .load-more-btn {
    padding: 18px 40px;
    background: linear-gradient(135deg, #007AFF 0%, #0056CC 100%);
    border: none;
    border-radius: 70px;
    color: #ffffff;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 20px rgba(0, 122, 255, 0.3);
    
    &:hover {
      background: linear-gradient(135deg, #0056CC 0%, #003D99 100%);
      transform: translateY(-2px);
      box-shadow: 0 8px 30px rgba(0, 122, 255, 0.4);
    }
    
    &:active {
      transform: translateY(0);
      box-shadow: 0 4px 20px rgba(0, 122, 255, 0.3);
    }
  }
}

// Responsive Design
@media (max-width: 1024px) {
  .portfolio-container {
    padding: 60px 30px;
  }
  
  .portfolio-grid {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    
    .portfolio-item.large {
      grid-column: span 1;
    }
  }
}

@media (max-width: 768px) {
  .portfolio-container {
    padding: 40px 20px;
  }
  
  .header-section {
    .page-title {
      font-size: 36px;
    }
  }
  
  .search-filter-section {
    flex-direction: column;
    gap: 16px;
    
    .search-bar {
      width: 100%;
      max-width: 400px;
    }
  }
  
  .category-filters {
    gap: 12px;
    
    .filter-tag {
      padding: 10px 20px;
      
      span {
        font-size: 13px;
      }
    }
  }
  
  .portfolio-grid {
    grid-template-columns: 1fr;
    
    .portfolio-item {
      &.large,
      &.medium,
      &.small {
        height: 220px;
      }
    }
  }
}

@media (max-width: 480px) {
  .header-section {
    .page-title {
      font-size: 28px;
    }
  }
  
  .category-filters {
    .filter-tag {
      padding: 8px 16px;
      
      span {
        font-size: 12px;
      }
    }
  }
}
</style>